// components/onlineform.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    citys: {
      type: Array,
      value: []
    },
    title: {
      type: String,
      value: '提交信息获取免费报价'
    },
    btnname: {
      type: String,
      value: '立即提交'
    },
    headshow:{
      type: Boolean,
      value: false
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    index: -1,
    multiArray: [['湖北省', '河南省', '其他城市'], ['武汉','十堰', '黄石', '襄阳', '枣阳', '随州', '荆州', '宜昌', '恩施', '荆门', '孝感', '黄冈']],
    multiIndex: [-1, -1],
  },


  /**
   * 组件的方法列表
   */
  methods: {
    formSubmit(e) {
      this.triggerEvent("submitform", e.detail);
      this.setData({
        intdata: '',
        multiIndex: [-1, -1],
      })
    },

    initdata(){
      this.setData({
        intdata: '',
        multiIndex: [-1, -1],
      })
    },
    bindMultiPickerChange: function (e) {
      console.log('picker发送选择改变，携带值为', e.detail.value)
      this.setData({
        multiIndex: e.detail.value
      })
    },
    bindMultiPickerColumnChange: function (e) {
      console.log('修改的列为', e.detail.column, '，值为', e.detail.value);
      var data = {
        multiArray: this.data.multiArray,
        multiIndex: this.data.multiIndex
      };
      data.multiIndex[e.detail.column] = e.detail.value;
      switch (e.detail.column) {
        case 0:
          switch (data.multiIndex[0]) {
            case 0:
              data.multiArray[1] = ['武汉', '十堰', '黄石', '襄阳', '枣阳', '随州', '荆州', '宜昌', '恩施', '荆门', '孝感', '黄冈'];
              break;
            case 1:
              data.multiArray[1] = ['信阳','平顶山','洛阳','新乡','开封','南阳'];
              break;
            case 2:
              data.multiArray[1] = [];
              break;
          }
          data.multiIndex[1] = 0;
          break;
        case 1:
          switch (data.multiIndex[0]) {
            case 0:
              console.log(data.multiIndex[1])
              break;
            case 1:
              console.log(data.multiIndex[1])
              break;
          }
          console.log(data.multiIndex);
          break;
      }
      this.setData(data);
    }

    
    
  }
})
